#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <ctime>

#define N 27

using namespace std; 

int n; 
string a, b, c; 
int x[3][N]; 
int val[N]; 
int used[N]; 
int guess_seq[N]; 
int first_visited[N]; 
int start_bit = 0; 

void init(void)
{
	int i, j, k; 
	
	for (i=0; i<n; i++) {
		used[i] = 0; 
		val[i] = -1; 
		first_visited[i] = -1; 
		x[0][n-1-i] = a[i] - 'A'; 
		x[1][n-1-i] = b[i] - 'A'; 
		x[2][n-1-i] = c[i] - 'A'; 
	}

	for (k=0, i=0; i<n; i++) {
		for (j=0; j<3; j++) {
			if (first_visited[x[j][i]]<0) {
				first_visited[x[j][i]] = i; 
				guess_seq[k++] = x[j][i]; 
			}
		}
	}
	/*
	for (i=0; i<n; i++) {
		cout<<(char)(guess_seq[i] + 'A')<<" "; 
	}
	cout<<endl; 

	for (i=0; i<n; i++) {
		cout<<guess_seq[i]<<" "; 
	}
	cout<<endl; 
	*/
}

bool is_possible(void)
{
	int i, A, B, C; 
	
	i = n-1; 
	A = val[x[0][i]]; 
	B = val[x[1][i]]; 
	C = val[x[2][i]]; 
	
	if (A+B>n) {
		return false; 
	}

	for (i=0; i<n; i++) {
		A = val[x[0][i]]; 
		B = val[x[1][i]]; 
		C = val[x[2][i]]; 

		if (A<0 || B<0 || C<0) {
			continue; 
		}

		if (((A+B)%n)!=C && ((A+B+1)%n)!=C) {
			return false; 
		} 
	}
	return true; 
}

void print_res(void)
{
	int i; 
	for (i=0; i<n; i++) {
		cout<<val[i]<<" "; 
	}
	cout<<endl; 
}

bool infer(int bit)
{
	int i; 
	
	//cout<<endl<<"enter infer(), bit="<<bit<<endl; 
	//print_res(); 
	
	if (is_possible()) {
		if (bit==n) {
			int A, B, C; 
			i = n-1; 
			A = val[x[0][i]]; 
			B = val[x[1][i]]; 
			C = val[x[2][i]]; 
			if((A+B==C) || (A+B+1)==C) {
				return true; 
			} else {
				//cout<<(char)(x[0][i]+'A')<<" + "<<(char)(x[1][i]+'A')<<" = "<<(char)(x[2][i]+'A')<<endl; 
				//cout<<"final: i="<<i<<" A="<<A<<" B="<<B<<" C="<<C<<" (A+B)%n="<<(A+B)%n<<" (A+B+1)%n="<<(A+B+1)%n<<endl; 
				//cout<<"return false, bit="<<bit<<" line="<<__LINE__<<endl; 
				return false; 
			}
		} 
	} else {
		//cout<<"return false, bit="<<bit<<" line="<<__LINE__<<endl; 
		return false; 
	}

	for (i=n-1; i>=0; i--) {
		//cout<<"bit="<<bit<<" i="<<i<<endl; 
		if (used[i]) {
			//cout<<"cont. line="<<__LINE__<<endl; 
			continue; 
		}
		assert(val[guess_seq[bit]]==-1); 
		val[guess_seq[bit]] = i; 
		used[i] = 1; 
		//cout<<"bit="<<bit<<" val["<<guess_seq[bit]<<"]="<<val[guess_seq[bit]]<<endl; 
		if (infer(bit+1)==true) {
			return true; 
		}
		used[i] = 0; 
		val[guess_seq[bit]] = -1; 
	}
	//cout<<"return false, bit="<<bit<<" line="<<__LINE__<<endl; 
	return false; 
}

int main()
{
//	freopen("p1092_2.in", "r", stdin); 

	cin>>n; 
	cin>>a>>b>>c; 

	init(); 

	infer(0);  

	print_res(); 

	return 0; 
}

